USE [MSE6DB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Policies]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Policies](
	[PolicyID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Policies_PolicyID]  DEFAULT (newid()),
	[Policy] [xml] NOT NULL,
 CONSTRAINT [PK_Policies] PRIMARY KEY NONCLUSTERED 
(
	[PolicyID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Properties]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Properties](
	[PropertyID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Properties_PropertyID]  DEFAULT (newid()),
	[Property] [xml] NOT NULL,
 CONSTRAINT [PK_Properties] PRIMARY KEY CLUSTERED 
(
	[PropertyID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Names]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Names](
	[RowID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Table1_RowID]  DEFAULT (newid()),
	[EntityID] [uniqueidentifier] NOT NULL,
	[EntityClass] [int] NOT NULL,
	[EntityName] [nvarchar](400) NOT NULL,
	[EntityDescription] [ntext] NULL,
 CONSTRAINT [PK_Names] PRIMARY KEY NONCLUSTERED 
(
	[RowID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [IX_Names] UNIQUE NONCLUSTERED 
(
	[EntityClass] ASC,
	[EntityName] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Events]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Events](
	[EventID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Events_EventID]  DEFAULT (newid()),
	[Name] [varchar](100) NOT NULL,
	[Description] [varchar](max) NULL,
 CONSTRAINT [PK_Events] PRIMARY KEY NONCLUSTERED 
(
	[EventID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Schemas]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Schemas](
	[SchemaID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Schemas_SchemaID]  DEFAULT (newid()),
	[PreferredPrefix] [nvarchar](10) NOT NULL,
	[Schema] [xml] NOT NULL,
 CONSTRAINT [PK_Schemas] PRIMARY KEY CLUSTERED 
(
	[SchemaID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[OperationGroups]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[OperationGroups](
	[OperationGroupID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_ServiceGroups_ServiceGroupID]  DEFAULT (newid())
 CONSTRAINT [PK_ServiceGroups] PRIMARY KEY NONCLUSTERED 
(
	[OperationGroupID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Operations]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Operations](
	[OperationID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Services_ServiceID]  DEFAULT (newid()),
	[PolicyID] [uniqueidentifier] NULL
 CONSTRAINT [PK_Services] PRIMARY KEY NONCLUSTERED 
(
	[OperationID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO


/****** Object:  Table [ServiceEngine].[EndPoints]    Script Date: 05/19/2008 03:09:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [ServiceEngine].[EndPoints](
	[EndPointID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_EndPoints_EndPointID]  DEFAULT (newid()),
	[BindingID] [uniqueidentifier] NOT NULL,
	[PolicyID] [uniqueidentifier] NULL,
	[TestCallsAccepted] [bit] NOT NULL CONSTRAINT [DF_EndPoints_TestCallsAccepted]  DEFAULT ((0)),
	[AutoOperationPubUpdate] [bit] NOT NULL CONSTRAINT [DF_EndPoints_AutoOperationPubUpdate]  DEFAULT ((0)),
	[AutoOperationActivationUpdate] [bit] NOT NULL CONSTRAINT [DF_EndPoints_AutoOperationActivationUpdate]  DEFAULT ((0)),
	[NamespaceURI] [ntext] NULL,
	[Configuration] [xml] NULL,
	[ServiceName] [nvarchar](200) NULL,
	[Port] [int] NULL,
 CONSTRAINT [PK_EndPoints] PRIMARY KEY NONCLUSTERED 
(
	[EndPointID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[EventRegistrations]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[EventRegistrations](
	[EventRegistrationID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_EventRegistrations_EventRegistrationID]  DEFAULT (newid()),
	[EventID] [uniqueidentifier] NOT NULL,
	[CallbackURI] [varchar](200) NOT NULL,
	[Expires] [datetime] NOT NULL CONSTRAINT [DF_EventRegistrations_Expires]  DEFAULT (dateadd(hour,(8),getdate())),
 CONSTRAINT [PK_EventRegistrations] PRIMARY KEY NONCLUSTERED 
(
	[EventRegistrationID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[MessageParts]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[MessageParts](
	[MessagePartID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_MessageParts_MessagePartID]  DEFAULT (newid()),
	[OperationVersionID] [uniqueidentifier] NOT NULL,
	[IsRequestMsg] [bit] NOT NULL,
	[Ordinal] [int] NOT NULL CONSTRAINT [DF_MessageParts_Order]  DEFAULT ((0)),
	[ElementName] [nvarchar](400) NOT NULL,
	[SchemaID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_MessageParts] PRIMARY KEY NONCLUSTERED 
(
	[MessagePartID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[SoapFaults]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[SoapFaults](
	[SoapFaultID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_SoapFaults_SoapFaultID]  DEFAULT (newid()),
	[OperationVersionID] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](400) NOT NULL,
	[ElementName] [nvarchar](400) NOT NULL,
	[Action] [nvarchar](256) NOT NULL,
	[ProtectionLevel] [nvarchar](32) NOT NULL,
	[SchemaID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_SoapFaults] PRIMARY KEY NONCLUSTERED 
(
	[SoapFaultID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[RuntimeServers_Endpoints]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[RuntimeServers_Endpoints](
	[RowID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Messengers_Endpoints_RowID]  DEFAULT (newid()),
	[RuntimeServerID] [uniqueidentifier] NOT NULL,
	[EndpointID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Messengers_Endpoints] PRIMARY KEY NONCLUSTERED 
(
	[RowID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints_PublishedOperations]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[EndPoints_PublishedOperations](
	[EndPoints_PublishedOperationsID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Services_EndPoints_Service_EndpointID]  DEFAULT (newid()),
	[EndpointID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_EndPoints_PublishedOperations_PublishedEndpointID]  DEFAULT (newid()),
	[OperationVersionID] [uniqueidentifier] NOT NULL,
	[OperationID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_EndPoints_PublishedOperations] PRIMARY KEY NONCLUSTERED 
(
	[EndPoints_PublishedOperationsID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [IX_OperationID_PublishedOperations] UNIQUE NONCLUSTERED 
(
	[EndpointID] ASC,
	[OperationID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [IX_PublishedOperations_EndPoints] UNIQUE NONCLUSTERED 
(
	[EndpointID] ASC,
	[OperationVersionID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints_AssociatedOperations]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[EndPoints_AssociatedOperations](
	[EndPoints_AssociatedOperationsID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_EndPoints_ActiveOperations_EndpointID]  DEFAULT (newid()),
	[EndpointID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_EndPoints_ActiveOperations_ActiveEndpointID]  DEFAULT (newid()),
	[OperationVersionID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_EndPoints_ActiveOperations] PRIMARY KEY NONCLUSTERED 
(
	[EndPoints_AssociatedOperationsID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [IX_ActiveOperations_EndPoints] UNIQUE NONCLUSTERED 
(
	[EndpointID] ASC,
	[OperationVersionID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints_AssociatedUddi]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[EndPoints_AssociatedUddi](
	[EndPoints_AssociatedUddiID] [uniqueidentifier] ROWGUIDCOL  NOT NULL DEFAULT (newid()),
	[RuntimeServerID] [uniqueidentifier] NOT NULL ,
	[EndpointID] [uniqueidentifier] NOT NULL ,
	[UddiTModelID] [nvarchar] (64) NOT NULL,
	[UddiServiceID] [nvarchar] (64) NOT NULL,
	[UddiBindingID] [nvarchar] (64) NOT NULL,
	[UddiWsdlUrl] [nvarchar] (400) NOT NULL,
	[UddiBindingUrl] [nvarchar] (400) NOT NULL,
 CONSTRAINT [PK_EndPoints_AssociatedUddi] PRIMARY KEY NONCLUSTERED 
(
	[EndPoints_AssociatedUddiID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [IX_EndPoints_AssociatedUddi] UNIQUE NONCLUSTERED 
(
	[EndpointID] ASC,
	[RuntimeServerID] ASC,
	[UddiTModelID] ASC,
	[UddiServiceID] ASC,
	[UddiBindingID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Operations_OperationGroups]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Operations_OperationGroups](
	[Operations_OperationGroupsID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Services_ServiceGroups_Services_ServiceGroupsID]  DEFAULT (newid()),
	[OperationID] [uniqueidentifier] NOT NULL,
	[OperationGroupID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Services_ServiceGroups] PRIMARY KEY CLUSTERED 
(
	[Operations_OperationGroupsID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[OperationVersions]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[OperationVersions](
	[OperationVersionID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_OperationVersions_OperationVersionID]  DEFAULT (newid()),
	[OperationID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_OperationVersions_OperationID]  DEFAULT (newid()),
	[VersionMajor] [int] NOT NULL CONSTRAINT [DF_OperationVersions_VersionMajor]  DEFAULT ((1)),
	[VersionMinor] [int] NOT NULL CONSTRAINT [DF_OperationVersions_VersionMinor]  DEFAULT ((0)),
	[VersionBuild] [int] NOT NULL CONSTRAINT [DF_OperationVersions_VersionBuild]  DEFAULT ((0)),
	[VersionQFE] [int] NOT NULL CONSTRAINT [DF_OperationVersions_VersionQFE]  DEFAULT ((0)),
	[IsPublic] [bit] NOT NULL CONSTRAINT [DF_OperationVersions_IsDiscoverable]  DEFAULT ((0)),
	[IsActive] [bit] NOT NULL CONSTRAINT [DF_OperationVersions_IsActive]  DEFAULT ((0)),
	[AutoResponse] [xml] NULL,
	[RequestTransformXSLT] [xml] NULL,
	[ResponseTransformXSLT] [xml] NULL,
	[ChannelID] [uniqueidentifier] NULL,
	[Moniker] [xml] NULL,
	[IsTestable] [bit] NULL CONSTRAINT [DF_OperationVersions_CanTest]  DEFAULT ((0)),
	[Description] [ntext] NULL,
 CONSTRAINT [PK_OperationVersions] PRIMARY KEY NONCLUSTERED 
(
	[OperationVersionID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO

/****** Object:  Table [ServiceEngine].[RuntimeServers]    Script Date: 05/19/2008 03:09:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [ServiceEngine].[RuntimeServers](
	[RuntimeServerID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Brokers_BrokerID]  DEFAULT (newid()),
	[CatalogURI] [nvarchar](400) NULL,
	[CatalogBindingID] [uniqueidentifier] NULL,
	[NotificationURI] [nvarchar](400) NULL,
	[NotificationBindingID] [uniqueidentifier] NULL,
	[BrokerURI] [nvarchar](400) NULL,
	[BrokerBindingID] [uniqueidentifier] NULL,
	[ListenerURI] [nvarchar](400) NULL,
	[ListenerBindingID] [uniqueidentifier] NULL,
	[HostName] [nvarchar](400) NULL,
 CONSTRAINT [PK_Brokers] PRIMARY KEY NONCLUSTERED 
(
	[RuntimeServerID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Channels]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Channels](
	[ChannelID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_ChannelTypes_ChannelTypeID]  DEFAULT (newid()),
	[BindingID] [uniqueidentifier] NOT NULL,
	[MonikerSchema] [xml] NOT NULL,
	[EditorAssembly] [nvarchar](max) NULL,
	[EditorTypeName] [nvarchar](max) NULL,
 CONSTRAINT [PK_ChannelTypes] PRIMARY KEY CLUSTERED 
(
	[ChannelID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Bindings]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Bindings](
	[BindingID] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_Table4_BindingID]  DEFAULT (newid()),
	[BindingConfig] [xml] NOT NULL,
 CONSTRAINT [PK_EndpointTypes] PRIMARY KEY CLUSTERED 
(
	[BindingID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [ServiceEngine.Entity_Policies]    Script Date: 03/29/2008 11:57:08 Start SGK******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ServiceEngine].[Entity_Policies]') AND type in (N'U'))
BEGIN
CREATE TABLE [ServiceEngine].[Entity_Policies](
	[RowID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_ServiceEngine.Entity_Policies_RowID]  DEFAULT (newid()),
	[EntityID] [uniqueidentifier] NOT NULL,
	[PolicyID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_ServiceEngine.Entity_Policies] PRIMARY KEY CLUSTERED 
(
	[RowID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** End SGK******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_Services_Policies]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[Operations]'))
ALTER TABLE [ServiceEngine].[Operations]  WITH CHECK ADD  CONSTRAINT [FK_Services_Policies] FOREIGN KEY([PolicyID])
REFERENCES [ServiceEngine].[Policies] ([PolicyID])
GO
ALTER TABLE [ServiceEngine].[Operations] CHECK CONSTRAINT [FK_Services_Policies]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_EndPoints_Bindings]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints]'))
ALTER TABLE [ServiceEngine].[EndPoints]  WITH CHECK ADD  CONSTRAINT [FK_EndPoints_Bindings] FOREIGN KEY([BindingID])
REFERENCES [ServiceEngine].[Bindings] ([BindingID])
GO
ALTER TABLE [ServiceEngine].[EndPoints] CHECK CONSTRAINT [FK_EndPoints_Bindings]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_EndPoints_Policies]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints]'))
ALTER TABLE [ServiceEngine].[EndPoints]  WITH CHECK ADD  CONSTRAINT [FK_EndPoints_Policies] FOREIGN KEY([PolicyID])
REFERENCES [ServiceEngine].[Policies] ([PolicyID])
GO
ALTER TABLE [ServiceEngine].[EndPoints] CHECK CONSTRAINT [FK_EndPoints_Policies]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_EventRegistrations_Events]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[EventRegistrations]'))
ALTER TABLE [ServiceEngine].[EventRegistrations]  WITH CHECK ADD  CONSTRAINT [FK_EventRegistrations_Events] FOREIGN KEY([EventID])
REFERENCES [ServiceEngine].[Events] ([EventID])
GO
ALTER TABLE [ServiceEngine].[EventRegistrations] CHECK CONSTRAINT [FK_EventRegistrations_Events]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_MessageParts_Schemas]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[MessageParts]'))
ALTER TABLE [ServiceEngine].[MessageParts]  WITH CHECK ADD  CONSTRAINT [FK_MessageParts_Schemas] FOREIGN KEY([SchemaID])
REFERENCES [ServiceEngine].[Schemas] ([SchemaID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[MessageParts] CHECK CONSTRAINT [FK_MessageParts_Schemas]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_RuntimeServers_Endpoints_RuntimeServers]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[RuntimeServers_Endpoints]'))
ALTER TABLE [ServiceEngine].[RuntimeServers_Endpoints]  WITH CHECK ADD  CONSTRAINT [FK_RuntimeServers_Endpoints_RuntimeServers] FOREIGN KEY([RuntimeServerID])
REFERENCES [ServiceEngine].[RuntimeServers] ([RuntimeServerID])
GO
ALTER TABLE [ServiceEngine].[RuntimeServers_Endpoints] CHECK CONSTRAINT [FK_RuntimeServers_Endpoints_RuntimeServers]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_Messengers_Endpoints_EndPoints]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[RuntimeServers_Endpoints]'))
ALTER TABLE [ServiceEngine].[RuntimeServers_Endpoints]  WITH CHECK ADD  CONSTRAINT [FK_Messengers_Endpoints_EndPoints] FOREIGN KEY([EndpointID])
REFERENCES [ServiceEngine].[EndPoints] ([EndPointID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[RuntimeServers_Endpoints] CHECK CONSTRAINT [FK_Messengers_Endpoints_EndPoints]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_EndPoints_PublishedOperations_EndPoints]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints_PublishedOperations]'))
ALTER TABLE [ServiceEngine].[EndPoints_PublishedOperations]  WITH CHECK ADD  CONSTRAINT [FK_EndPoints_PublishedOperations_EndPoints] FOREIGN KEY([EndpointID])
REFERENCES [ServiceEngine].[EndPoints] ([EndPointID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[EndPoints_PublishedOperations] CHECK CONSTRAINT [FK_EndPoints_PublishedOperations_EndPoints]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_EndPoints_PublishedOperations_Operations]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints_PublishedOperations]'))
ALTER TABLE [ServiceEngine].[EndPoints_PublishedOperations]  WITH CHECK ADD  CONSTRAINT [FK_EndPoints_PublishedOperations_Operations] FOREIGN KEY([OperationID])
REFERENCES [ServiceEngine].[Operations] ([OperationID])
GO
ALTER TABLE [ServiceEngine].[EndPoints_PublishedOperations] CHECK CONSTRAINT [FK_EndPoints_PublishedOperations_Operations]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_EndPoints_PublishedOperations_OperationVersions]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints_PublishedOperations]'))
ALTER TABLE [ServiceEngine].[EndPoints_PublishedOperations]  WITH CHECK ADD  CONSTRAINT [FK_EndPoints_PublishedOperations_OperationVersions] FOREIGN KEY([OperationVersionID])
REFERENCES [ServiceEngine].[OperationVersions] ([OperationVersionID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[EndPoints_PublishedOperations] CHECK CONSTRAINT [FK_EndPoints_PublishedOperations_OperationVersions]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_EndPoints_ActiveOperations_EndPoints]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints_AssociatedOperations]'))
ALTER TABLE [ServiceEngine].[EndPoints_AssociatedOperations]  WITH CHECK ADD  CONSTRAINT [FK_EndPoints_ActiveOperations_EndPoints] FOREIGN KEY([EndpointID])
REFERENCES [ServiceEngine].[EndPoints] ([EndPointID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[EndPoints_AssociatedOperations] CHECK CONSTRAINT [FK_EndPoints_ActiveOperations_EndPoints]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_EndPoints_ActiveOperations_OperationVersions]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints_AssociatedOperations]'))
ALTER TABLE [ServiceEngine].[EndPoints_AssociatedOperations]  WITH CHECK ADD  CONSTRAINT [FK_EndPoints_ActiveOperations_OperationVersions] FOREIGN KEY([OperationVersionID])
REFERENCES [ServiceEngine].[OperationVersions] ([OperationVersionID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[EndPoints_AssociatedOperations] CHECK CONSTRAINT [FK_EndPoints_ActiveOperations_OperationVersions]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_Operations_OperationGroups_OperationGroups]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[Operations_OperationGroups]'))
ALTER TABLE [ServiceEngine].[Operations_OperationGroups]  WITH CHECK ADD  CONSTRAINT [FK_Operations_OperationGroups_OperationGroups] FOREIGN KEY([OperationGroupID])
REFERENCES [ServiceEngine].[OperationGroups] ([OperationGroupID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[Operations_OperationGroups] CHECK CONSTRAINT [FK_Operations_OperationGroups_OperationGroups]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_Operations_OperationGroups_Operations]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[Operations_OperationGroups]'))
ALTER TABLE [ServiceEngine].[Operations_OperationGroups]  WITH CHECK ADD  CONSTRAINT [FK_Operations_OperationGroups_Operations] FOREIGN KEY([OperationID])
REFERENCES [ServiceEngine].[Operations] ([OperationID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[Operations_OperationGroups] CHECK CONSTRAINT [FK_Operations_OperationGroups_Operations]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_OperationVersions_Channels]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[OperationVersions]'))
ALTER TABLE [ServiceEngine].[OperationVersions]  WITH CHECK ADD  CONSTRAINT [FK_OperationVersions_Channels] FOREIGN KEY([ChannelID])
REFERENCES [ServiceEngine].[Channels] ([ChannelID])
GO
ALTER TABLE [ServiceEngine].[OperationVersions] CHECK CONSTRAINT [FK_OperationVersions_Channels]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_OperationVersions_Operations]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[OperationVersions]'))
ALTER TABLE [ServiceEngine].[OperationVersions]  WITH CHECK ADD  CONSTRAINT [FK_OperationVersions_Operations] FOREIGN KEY([OperationID])
REFERENCES [ServiceEngine].[Operations] ([OperationID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[OperationVersions] CHECK CONSTRAINT [FK_OperationVersions_Operations]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_RuntimeServers_CatalogBindings]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[RuntimeServers]'))
ALTER TABLE [ServiceEngine].[RuntimeServers]  WITH NOCHECK ADD  CONSTRAINT [FK_RuntimeServers_CatalogBindings] FOREIGN KEY([CatalogBindingID])
REFERENCES [ServiceEngine].[Bindings] ([BindingID])
GO
ALTER TABLE [ServiceEngine].[RuntimeServers] NOCHECK CONSTRAINT [FK_RuntimeServers_CatalogBindings]
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_RuntimeServers_BrokerBindings]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[RuntimeServers]'))
ALTER TABLE [ServiceEngine].[RuntimeServers]  WITH NOCHECK ADD  CONSTRAINT [FK_RuntimeServers_BrokerBindings] FOREIGN KEY([BrokerBindingID])
REFERENCES [ServiceEngine].[Bindings] ([BindingID])
GO
ALTER TABLE [ServiceEngine].[RuntimeServers] NOCHECK CONSTRAINT [FK_RuntimeServers_BrokerBindings]
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_RuntimeServers_NotificationBindings]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[RuntimeServers]'))
ALTER TABLE [ServiceEngine].[RuntimeServers]  WITH NOCHECK ADD  CONSTRAINT [FK_RuntimeServers_NotificationBindings] FOREIGN KEY([NotificationBindingID])
REFERENCES [ServiceEngine].[Bindings] ([BindingID])
GO
ALTER TABLE [ServiceEngine].[RuntimeServers] NOCHECK CONSTRAINT [FK_RuntimeServers_NotificationBindings]
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_RuntimeServers_ListenerBindings]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[RuntimeServers]'))
ALTER TABLE [ServiceEngine].[RuntimeServers]  WITH NOCHECK ADD  CONSTRAINT [FK_RuntimeServers_ListenerBindings] FOREIGN KEY([ListenerBindingID])
REFERENCES [ServiceEngine].[Bindings] ([BindingID])
GO
ALTER TABLE [ServiceEngine].[RuntimeServers] NOCHECK CONSTRAINT [FK_RuntimeServers_ListenerBindings]
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_ChannelTypes_Bindings]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[Channels]'))
ALTER TABLE [ServiceEngine].[Channels]  WITH CHECK ADD  CONSTRAINT [FK_ChannelTypes_Bindings] FOREIGN KEY([BindingID])
REFERENCES [ServiceEngine].[Bindings] ([BindingID])
GO
ALTER TABLE [ServiceEngine].[Channels] CHECK CONSTRAINT [FK_ChannelTypes_Bindings]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_EndPoints_AssociatedUddi_EndPoints]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[EndPoints_AssociatedUddi]'))
ALTER TABLE [ServiceEngine].[EndPoints_AssociatedUddi]  WITH CHECK ADD  CONSTRAINT [FK_EndPoints_AssociatedUddi_EndPoints] FOREIGN KEY([EndpointID])
REFERENCES [ServiceEngine].[EndPoints] ([EndpointID])
GO
ALTER TABLE [ServiceEngine].[EndPoints_AssociatedUddi] CHECK CONSTRAINT [FK_EndPoints_AssociatedUddi_EndPoints]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_SoapFaults_OperationVersions]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[SoapFaults]'))
ALTER TABLE [ServiceEngine].[SoapFaults]  WITH CHECK ADD  CONSTRAINT [FK_SoapFaults_OperationVersions] FOREIGN KEY([OperationVersionID])
REFERENCES [ServiceEngine].[OperationVersions] ([OperationVersionID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_SoapFaults_Schemas]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[SoapFaults]'))
ALTER TABLE [ServiceEngine].[SoapFaults]  WITH CHECK ADD  CONSTRAINT [FK_SoapFaults_Schemas] FOREIGN KEY([SchemaID])
REFERENCES [ServiceEngine].[Schemas] ([SchemaID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [ServiceEngine].[SoapFaults] CHECK CONSTRAINT [FK_SoapFaults_Schemas]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[ServiceEngine].[FK_Entity_Policies_Policies]') AND parent_object_id = OBJECT_ID(N'[ServiceEngine].[Entity_Policies]'))
ALTER TABLE [ServiceEngine].[Entity_Policies]  WITH CHECK ADD  CONSTRAINT [FK_Entity_Policies_Policies] FOREIGN KEY([PolicyID])
REFERENCES [ServiceEngine].[Policies] ([PolicyID])
GO
ALTER TABLE [ServiceEngine].[Entity_Policies] CHECK CONSTRAINT [FK_Entity_Policies_Policies]
GO